#include "apue.h"
int main(void) {
	pid_t pid;
	int status;

	// 正常退出
	if ((pid = fork()) < 0)
		err_sys("fork error");
	else if (pid == 0)
		exit(7);

	if (wait(&status) != pid)
		err_sys("wait error");
	pr_exit(status);

	// 异常退出
	if ((pid = fork()) < 0)
		err_sys("fork error");
	else if (pid == 0)
		abort();

	if (wait(&status) != pid)
		err_sys("wait error");
	pr_exit(status);

	// divide by 0 generates SIGFPE
	if ((pid = fork()) < 0)
		err_sys("fork error");
	else if (pid == 0)
		status /= 0;

	if (wait(&status) != pid)
		err_sys("wait error");
	pr_exit(status);
	

	exit(0);
}
